home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-22 | 61.1 KB | 1,992 lines |
- ;-------T-------T-------T-------T-------T-------T-------T-------T-------T-------T-------T----x
- ;Labels (16) Instructions (48) Comments (30++)
- ; $VER: HostFuncs 1.2
- ; Started: 980327
- ; Location: Waratah.au, Malmö.se
- ; Last drunk: 7 weeks ago
- ; Last stoned: 4 weeks ago (M)
- ; Mood: Homesick
- ; Todays wishes: 1> LAG 2> Return to Sweden
- ; Changed: 980328, 980329, 980330, 980331, 980403, 980412, 980413
- ; Changed: 980415, 980416, 980417, 980418, 980818, 980820, 980821
- ; Changed: 980827, 980907
-
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * ... *
- * ::::::.::::::. :::::::. .:: ::::::. .::::. ::: *
- * .::.::'.::..:: .::..::' ...`::..::..'' .::. `' *
- * ::: :::: ::::::: `::.::::::'::::.::.::::::' ::: *
- * .................................................. *
- * *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-
- ; Captain's log...
- ;
- ; 980328:0005 (038) Started this source yesterday. It's purpose is to reduce the amount of
- ; code needed to adapt a player to the ravescope. It will contain easy to use
- ; function calls that will take care of most of the chores with establishing a
- ; connection between a ravescope host (the link between the RaveScope and the
- ; player) and the RaveScope.
- ; 980331:0820 (038) Finally all (or at least most) routines are completed. I'll try to change
- ; DeliRave into using these host functions now.
- ; 980403:1532 (039) Hrm, I'm still changing DeliRave and the RaveScope... A lot to be done!
- ; I changed the message port names, so that they will now always be called
- ; RaveScope-Host.x where x is a number starting from 0. This will make it easier
- ; for the RaveScope to look for hosts. The MakeMsgPort routine will look for a
- ; name that is not in use, and use that.
- ; 980413:1758 (041) This works quite ok with DeliRave now!
- ; 980413:1810 (041) Corrected bug with checking the config-id.
- ; ** Made the HandleMsg routine recognize the RMSG_RAVEBUSY and RMSG_RAVEREADY
- ; messages. But they produce nothing and I don't know of what use they may be.
- ; 980413:1855 (041) Added the rh_oPlaying flag. The host must set this when its player is
- ; playing and clear it when it stops. When GrabRave is called and the RaveScope
- ; is grabbed, a RMSG_PLYACTIVE msg will be sent if the host is playing.
- ; 980416:0315 (043) Added the rh_UpdateChans routine. It will call ms_Get4Upd to get a
- ; channel header, then it may also make sure there's enough channels in there,
- ; and finally call the host's routine to update these structures.
- ; 980417:2237 (044) The rh_GotRave routine, which is called whenever the RaveScope tells us
- ; to grab it, will now check the local play-flag, and if it is set send a
- ; RMSG_PLYACTIVE message to the RaveScope.
- ; 980418:0117 (044) Realized that this could mean sending a message that was already sent,
- ; since I only had one message reserved. Changed the message routines to allocate
- ; messages as they were sent, and freed as they got back.
- ; 980818:1754 (050) Added the routine rh_PlyActive. Whenever a host gets a message from its
- ; player that it is now playing, this routine should be called. It will inform
- ; the ravescope of the new state, if the host owns the RaveScope. If not it will
- ; try to grab it first.
- ; 980821:0023 (052) Changed some routines to return the most important value in d0, so that these
- ; functions can be used from a c/++ source. May have created minor bugs as I did this.
- ; 980827:1717 (054) Modified the rh_OpenLibs so that it can be called several times without
- ; failing or opening the same libs more than once. If a library cannot be opened, all
- ; successfully opened libs will be closed before error is returned. Also made this
- ; routine and CloseLibs public. I had to do this, because Eagleplayer needs to access
- ; dos.library before InitHost is called.
- ; 980827:1817 (054) Corrected bug, the 020+ check assumed that a6 was = sysbase. When it was not
- ; it would fail on my computer. Found at that it would crash when it failed, and I'm
- ; right now trying to find out why. Found minor bug while doing this, the last 2 channel
- ; structures has never been freed, because to step to the next one, I increased the
- ; wrong address register.
- ; 980827:1824 (054) It crashed because in the host I continued using the now cleared and freed
- ; dosbase.
- ; 980827:1841 (054) A no 020 found requester will now pop up when appropriate.
- ; 980907:1322 (058) Added the flag rh_oFromWB. It will be set if the host starts the ravescope
- ; itself, and then or:ed into the RaveScopes corresponding flag. Then it is cleared.
- ; This will make the RaveScope pop up easy requesters, instead of printing any error
- ; message to nil:
- ; 980922:0007 (065) *** Released version 1.2 on Aminet with this source (065).
-
- IFD _PHXASS_
- MACHINE 68020
- ENDC
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Public functions
-
- XDEF _rh_AddSig * Add given signal to the signal mask
- XDEF _rh_AllocMsg * Allocate a ravemessage and init it
- XDEF _rh_AllocSig * Alloc a signal and add it to the mask
- XDEF _rh_ClrChans * Clear the supplied channel structure
- XDEF _rh_CloseLibs * Close all opened libraries
- XDEF _rh_FailMsg * Reply supplied message with failurecode set
- XDEF _rh_FindRave * Try to find the RaveScope
- XDEF _rh_FreeHost * Free/close everything done in rh_InitHost
- XDEF _rh_FreeMsg * Free a RaveMsg
- XDEF _rh_FreeSig * Free a signal and remove it from the mask
- XDEF _rh_GetMsg * Try to get a msg from the host's msgport
- XDEF _rh_GotRave * Handle and reply the supplied GRABRAVE msg
- XDEF _rh_GrabRave * Try to grab/launch the RaveScope
- XDEF _rh_HandleMsg * Handle and reply the supplied ravemsg
- XDEF _rh_InitHost * Create everything a RaveHost may need
- XDEF _rh_LoadConfig * Load and parse the configuration file
- XDEF _rh_LostRave * Handle and reply the supplied LEAVERAVE msg
- XDEF _rh_NukeChans * Clear the host's channel structures
- XDEF _rh_OpenLibs * Open dos, intuition and reqtools.library
- XDEF _rh_ParseCfg * Parse the config
- XDEF _rh_PlyActive * Call when your player starts playing
- XDEF _rh_ProcMsgs * Handle all msgs currently in host's msgport
- XDEF _rh_PutMsg * PutMsg() a RaveMsg to the RaveScope
- XDEF _rh_RaveQuit * Handle and reply the supplied RAVEQUIT msg
- XDEF _rh_RemSig * Remove given signal from the signal mask
- XDEF _rh_ResetCfg * Reset the config to default values
- XDEF _rh_SignalRave * PutMsg() to Rave AND wait IF we have it
- XDEF _rh_TellRave * PutMsg() to Rave IF we have it
- XDEF _rh_UpdateChans * Call when updating the channel structures
- XDEF _rh_WaitMsg * Wait() for the specified message to return
- XDEF _rh_WaitPutMsg * PutMsg() to Rave AND wait for reply
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Includes &c
-
- SECTION HostCode,Code
-
- INCDIR include:
- INCLUDE exec/exec_lib.i
- INCLUDE exec/exec.i
- INCLUDE exec/tasks.i
- INCLUDE devices/timer_lib.i
- INCLUDE devices/timer.i
- INCLUDE dos/dos_lib.i
- INCLUDE dos/dos.i
- INCLUDE dos/dostags.i
- INCLUDE graphics/graphics_lib.i
- INCLUDE graphics/gfx.i
- INCLUDE hardware/intbits.i
- INCLUDE intuition/intuition_lib.i
- INCLUDE intuition/intuition.i
- INCLUDE libraries/gadtools_lib.i
- INCLUDE libraries/gadtools.i
- INCLUDE libraries/reqtools.i
- INCLUDE libraries/reqtools_lib.i
- INCDIR ""
- INCLUDE include/monoscope.i
- INCLUDE include/ravescope.i
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Constants
-
- NO: EQU 0
- YES: EQU 1
- MYDEBUG: EQU NO
- DEBTIME: EQU 0
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Macros
-
- PUSH: MACRO
- IFC "\1","ALL"
- movem.l d0-a6,-(sp)
- ELSE
- movem.l \1,-(sp)
- ENDC
- ENDM
-
- POP: MACRO
- IFC "\1","ALL"
- movem.l (sp)+,d0-a6
- ELSE
- movem.l (sp)+,\1
- ENDC
- ENDM
-
- CALLLVO: MACRO
- jsr _LVO\1(a6)
- ENDM
- JUMPLVO: MACRO
- jmp _LVO\1(a6)
- ENDM
-
- CALLEXE: MACRO
- move.l rh_oSysBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
- JUMPEXE: MACRO
- move.l rh_oSysBase(a5),a6
- jmp _LVO\1(a6)
- ENDM
-
- CALLDOS: MACRO
- move.l rh_oDOSBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
- JUMPDOS: MACRO
- move.l rh_oDOSBase(a5),a6
- jmp _LVO\1(a6)
- ENDM
-
- CALLITN: MACRO
- move.l rh_oIntuiBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
- JUMPITN: MACRO
- move.l rh_oIntuiBase(a5),a6
- jmp _LVO\1(a6)
- ENDM
-
- CALLREQ: MACRO
- move.l rh_oRTBase(a5),a6
- jsr _LVO\1(a6)
- ENDM
- JUMPREQ: MACRO
- move.l rh_oRTBase(a5),a6
- jmp _LVO\1(a6)
- ENDM
-
- IFNE MYDEBUG * Debug macro. Link with include:
- XRef KPrintF * link/debug.lib & link/amiga.lib
- ENDC
-
- SFORBID: MACRO
- PUSH d0-d1/a0-a1/a6
- CALLEXE Forbid
- POP d0-d1/a0-a1/a6
- ENDM
-
- SPERMIT: MACRO
- PUSH d0-d1/a0-a1/a6
- CALLEXE Permit
- POP d0-d1/a0-a1/a6
- ENDM
-
- DBUG: MACRO
- IFNE MYDEBUG
- bra .Ok\@
- .Str\@: dc.b "HOST: ",\1,0
- EVEN
- .Ok\@: DBUGIT .Str\@
- ENDC
- ENDM
-
- DBUGIT: MACRO
- IFNE MYDEBUG
- PUSH ALL
- move.l 4.w,a6
- CALLLVO Forbid
- lea \1,a0
- CLEARA a1
- jsr KPrintF
- CALLLVO Permit
- IFNE DEBTIME
- move.l rh_oDOSBase(a5),d0
- beq .Skip\@
- move.l d0,a6
- move.l #DEBTIME,d1
- CALLDOS Delay
- ENDC
- .Skip\@: POP ALL
- ENDC
- ENDM
-
- LEASTR: MACRO
- bsr .skip\@
- dc.b \1,0
- EVEN
- .skip\@: move.l (sp)+,\2
- ENDM
-
- SETERR: MACRO
- tst.l rh_oError(a5) ;Error code already set?
- bne .Skip\@ ;Yes, skip
- move.l \1,rh_oError(a5) ;Set new error
- .Skip\@:
- ENDM
-
- ERRMSG: MACRO
- LEASTR \1,a0
- SETERR a0
- ENDM
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Add given signal (d0) to the signal mask *
- * *
- * void rh_AddSig(BYTE signal, struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS d0.b Signal number *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED d1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_AddSig: move.l rh_oSigMask(a5),d1
- bset.l d0,d1
- move.l d1,rh_oSigMask(a5)
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Allocate a ravemessage and init it *
- * *
- * struct RaveMsg *msg = rh_AllocMsg(struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0 Pointer to the message or NULL for failure *
- * *
- * FLAGS EQ The message could not be allocated *
- * NE The message could be allocated *
- * *
- * CHANGED d0 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_AllocMsg: DBUG "Allocating a message.\n"
- PUSH d1/a0-a1/a6
- move.l #rmsg_SIZEOF,d0
- move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
- CALLEXE AllocVec
- tst.l d0
- beq .Exit
- move.l d0,a1
- move.l a5,MN_REPLYPORT(a1) * Init the RaveMsg
- move.w #rmsg_SIZEOF,MN_LENGTH(a1)
- .Exit: POP d1/a0-a1/a6
- rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Allocate a signal and add it to the signal mask (rh_oSigMask) *
- * *
- * BYTE signal = rh_AllocSig(struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.b The signal or -1 if none could be allocated *
- * *
- * FLAGS GE A signal was allocated *
- * MI No signal could be allocated *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_AllocSig: DBUG "Allocating signal...\n"
- moveq #-1,d0
- CALLEXE AllocSignal * Allocate the signal
- tst.b d0
- bmi .Error
- bsr _rh_AddSig * Add it to the mask
- bra .Out
- .Error: ERRMSG "Couldn't allocate a signal!\n"
- .Out: tst.b d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Close all opened libraries. Done automatically in rh_FreeHost *
- * *
- * void rh_CloseLibs(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED none *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_CloseLibs: PUSH d0-d1/d7/a0-a1/a4 * Close all opened libraries
- DBUG "Closing all libraries...\n"
- lea rh_oDOSBase(a5),a4
- moveq #3-1,d7
- .ClLibLop: move.l (a4),d0
- beq .LibNotOp
- movea.l d0,a1
- CALLEXE CloseLibrary
- .LibNotOp: clr.l (a4)+
- dbra d7,.ClLibLop
- POP d0-d1/d7/a0-a1/a4
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Fill all channel structures (pointed to by the specified header structure) *
- * with values that guarantees that they will not be used in the display. *
- * *
- * void rh_ClrChans(struct ScopeHeader *header) *
- * a4 *
- * *
- * INPUTS a4.l Pointer to a scopeheader structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED none *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_ClrChans: PUSH d0-d1/a0
- move.l scph_oChannels(a4),d0
- beq .Exit
- move.l d0,a0
- move.w scph_oMaxChans(a4),d1
- CLEAR d0
- bra .BegInit
- .Init: move.l d0,scpc_oSampleLoop(a0)
- move.l d0,scpc_oSamplePos(a0)
- move.l d0,scpc_oSampleLeft(a0) * No samples left to disp
- move.l d0,scpc_oLoopSize(a0) * No loop left to disp
- move.w d0,scpc_oVolume(a0) * No volume => don't disp
- move.l d0,scpc_oFreq(a0) * No frequency => no update
- adda.w #scpc_SIZEOF,a0
- .BegInit: dbra d1,.Init
- .Exit: POP d0-d1/a0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Reply to a message that could not be handled (return RMSG_FAILURE) *
- * *
- * void rh_FailMsg(struct Message *msg, struct RaveHost *host) *
- * a1 a5 *
- * *
- * INPUTS a1.l Pointer to the message *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * FLAGS MI Always set *
- * *
- * CHANGED d0-d1/a0-a1/a6 (a6 = SysBase) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_FailMsg: DBUG "Replying msg with RMSG_FAILURE!\n"
- move.w #RMSG_FAILURE,rmsg_oResult(a1)
- CALLEXE ReplyMsg
- moveq #-1,d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Try to find the RaveScope. Caller must Permit() if the RavePort was found. *
- * *
- * struct RaveScope *raveport = rh_FindRave(UWORD seconds, struct RaveHost *host) *
- * d0 d0 a5 *
- * *
- * INPUTS d0.w Number of seconds to keep trying *
- * a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.l Pointer to the RaveScope's port (RaveBase) or NULL *
- * *
- * FLAGS NE Everything ok, RaveBase supplied in d0 *
- * EQ The RaveScope is not running *
- * *
- * CHANGED d0-d1/a0-a1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_FindRave: DBUG "** Entered rh_FindRave. Trying to find the RaveScope...\n"
- PUSH d2-d7/a2-a4/a6
- move.w d0,d7 * d7 = seconds to try
- bra .Find
- .Wait: CALLLVO Permit
- moveq #50,d1 * Wait a second
- CALLDOS Delay
-
- .Find: CALLEXE Forbid
- lea rh_RSPortName,a1
- DBUG 'FindPort("RaveScope")...\n'
- CALLLVO FindPort * Try to find the RaveScope
- tst.l d0
- dbne d7,.Wait
- beq .NoRave
-
- .Found: DBUG "RaveBase found. Comparing ID:s...\n" * a4 = RaveBase, check ID:s
- move.l d0,a4
- cmp.l #RAVE_ID,rs_oID(a4)
- beq .RaveOk
-
- .NoRave: CALLLVO Permit
- DBUG "Returning FAILURE.\n"
- CLEAR d0
- bra .Out
- .RaveOk: DBUG "Returning SUCCESS.\n"
- move.l a4,d0 * Signal RaveBase found
- .Out: POP d2-d7/a2-a4/a6
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Free everything opened/allocated by rh_InitHost *
- * *
- * void rh_FreeHost(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the hosts RaveHost structure. *
- * *
- * CHANGED d0-d1/a0-a1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_FreeHost: DBUG "** Entered rh_FreeHost\n"
- bsr rh_FreeMsgPort * Release RaveScope, rem msgport
- bsr rh_FreeChHds * Free channel headers
- bsr rh_FreeCfg * Free config
- bsr _rh_CloseLibs * Close libs
- bra rh_FreeRHStr * Free RaveHost struct (if allocd)
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Free a RaveMsg *
- * *
- * void rh_FreeMsg(struct RaveMsg *msg, struct RaveHost *host) *
- * a1 a5 *
- * *
- * INPUTS a1.l Pointer to the RaveMsg to free *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED a1 (NULLed) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_FreeMsg: DBUG "Freeing one of our messages.\n"
- PUSH d0-d1/a0/a6
- CALLEXE FreeVec
- CLEARA a1
- .Exit: POP d0-d1/a0/a6
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Free a signal and remove it from the signal mask (rh_oSigMask) *
- * *
- * void rh_FreeSig(BYTE *signal, struct RaveHost *host) *
- * a0 a5 *
- * *
- * INPUTS a0.l Pointer to the signal number *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_FreeSig: DBUG "Freeing the signal...\n"
- move.b (a0),d0
- bmi .Exit
- st (a0)
- bsr _rh_RemSig
- JUMPEXE FreeSignal
- .Exit: rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Try to get a message from the host's messageport. *
- * *
- * struct Message *msg, UWORD class = rh_GetMsg(struct RaveHost *host) *
- * d0 d1 a5 *
- * *
- * INPUTS a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.l Pointer to the message or NULL if none *
- * d1.w The recieved message's class *
- * *
- * FLAGS NE Got a message *
- * EQ Did not get a message *
- * *
- * CHANGED d0-d1/a0-a1/a6 (a6 = SysBase) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_GetMsg: move.l a5,a0
- CALLEXE GetMsg * Get the message
- tst.l d0 * Any?
- bne .GotMsg * Yes
- DBUG "The message flow has stopped.\n" * No, WaitPort() again.
- CLEAR d0
- bra .Out
- .GotMsg: move.l d0,a1
- move.w rmsg_oType(a1),d1
- IFNE MYDEBUG
- move.w d1,d0
- SFORBID
- DBUG "Got "
- bsr _rh_IdentMsg
- DBUGIT (a0)
- LEASTR "\n",a0
- DBUGIT (a0)
- SPERMIT
- ENDC
- move.l a1,d0
- .Out: rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Handle the RMSG_GRABRAVE message and reply it with the success code set. *
- * *
- * void rh_GotRave(struct Message *msg, struct RaveHost *host) *
- * a1 a5 *
- * *
- * INPUTS a1.l Pointer to the message *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * FLAGS GT Always set *
- * *
- * CHANGED d0-d1/a0-a1/a6 (a6 = SysBase) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_GotRave: DBUG "Grabbing the RaveScope.\n"
- DBUG "Replying to RMSG_GRABRAVE message.\n"
- move.l rmsg_oData(a1),rh_oRaveBase(a5) * Store supplied RaveBase
- move.w #RMSG_SUCCESS,rmsg_oResult(a1)
- CALLEXE ReplyMsg
- tst.b rh_oPlaying(a5) * Is our player playing?
- beq .NoPlay * No
- move.w #RMSG_PLYACTIVE,d0 * Yes, inform the RaveScope
- bsr _rh_PutMsg
- IFNE MYDEBUG
- moveq #1,d0
- rts
- ENDC
-
- .NoPlay: DBUG "rh_oPlaying is CLEARED.\n"
- moveq #1,d0
- rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Try to grab the RaveScope. Launch it if it is not present. Ask for its *
- * path (via reqtools) if current path (in prefs) is not known/invalid. *
- * *
- * LONG success = rh_GrabRave(struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.l -1, 1 or 0, corresponds to flags below. *
- * a5.l Pointer to the RaveHost structure *
- * *
- * FLAGS MI The RaveScope could not be grabbed. *
- * GT Everything fine, the RaveScope is grabbed. *
- * EQ Serious error, host should quit if possible *
- * *
- * CHANGED d0-d1/a0-a1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_GrabRave: PUSH d2-d7/a2-a4/a6
- DBUG "** Entered rh_GrabRave.\n"
- tst.l a5
- beq .Error
- tst.l rh_oRaveBase(a5) * RaveScope not already grabbed?
- bne .Grabbed
-
- CLEAR d0
- bsr _rh_FindRave * RaveScope present?
- bne .RaveOk * Yes, wait for it to grab us
-
- lea ([rh_oCfgPtr,a5],hcfg_oRaveName),a4 * a4 = current RaveScope path
- tst.b (a4)
- bne .NameOk
-
- .ReqName: DBUG "Ravename not present/valid. Allocating filerequester.\n"
- move.l #RT_FILEREQ,d0
- CLEARA a0
- CALLREQ rtAllocRequestA
- move.l d0,d5 * d5 = RT filerequest
- beq .Error
-
- DBUG "Calling filerequester.\n"
- movea.l d5,a1 * Ask for file
- lea rh_FileName,a2
- lea rh_AskFileTxt,a3
- lea rh_ReqTags,a0
- CALLLVO rtFileRequestA
- tst.l d0 * Any file selected?
- bne .ReqOk
- bsr .FreeReq
- bra .Fail
-
- .ReqOk: DBUG "AddPart()ing path.\n"
- move.l d5,a0
- move.l rtfi_Dir(a0),d2 * Add the path
- move.l a4,d1
- clr.b (a4)
- move.l #500-1,d3 * Size of ravename buffer
- CALLDOS AddPart
- tst.l d0 * Buffer overflowed?
- bne .PathOk
- bsr .FreeReq
- bra .Error
-
- .PathOk: DBUG "AddPart()ing filename.\n"
- move.l #rh_FileName,d2 * Add the filename
- move.l a4,d1 * To the path in the ravename
- CALLLVO AddPart
- move.l d0,d2
- bsr .FreeReq
- tst.l d2 * Buffer overflowed?
- beq .Error
-
- .NameOk: DBUG "Ravename obtained : "
- DBUGIT (a4)
- IFNE MYDEBUG
- LEASTR "\n",a3
- DBUGIT (a3)
- ENDC
-
- DBUG "Trying to Lock() the exe.\n" * Make sure name is ok
- move.l a4,d1
- move.l #ACCESS_READ,d2
- CALLDOS Lock
- move.l d0,d1
- beq .ReqName
- CALLLVO UnLock
-
- DBUG "Trying to start the RaveScope...\n" * Open NIL:s
- DBUG "Opening NIL:s\n"
- bsr .OpenNIL
- move.l d0,rh_NilInput+4
- beq .Error
- bsr .OpenNIL
- move.l d0,rh_NilOutput+4
- bne .NILsOk
- bsr .CloseNILs
- bra .Error
-
- .NILsOk: DBUG "Calling SystemTagList()\n" * Execute EagleRave
- st rh_oFromWB(a5)
- move.l a4,d1
- move.l #rh_ExeTags,d2
- CALLDOS SystemTagList
-
- IFNE MYDEBUG * Show it's result-code
- bra .DoDebug
- .DebugMsg: dc.b "HOST: SystemTagList() returned : $"
- .DebugNum: dc.b " .\n",0
- EVEN
- .DoDebug: lea .DebugNum,a1
- bsr rh_D0toASCII
- DBUGIT .DebugMsg
- ENDC
-
- not.l d0 * Could the RaveScope be started?
- bne .Executed * Yes
- bsr .CloseNILs * No, close NIL filehandles
- bra .Error
-
- .Executed: DBUG "Waiting for the RavePort to appear.\n" * Wait max 20 seconds for it
- moveq #20,d0
- bsr _rh_FindRave * This routine will Forbid()
- beq .Fail * unless it fails (EQ)
-
- .RaveOk: DBUG "The RavePort has been found OK.\n"
- move.l d0,a0 * Now or this wb flag into the RaveScope
- move.b rs_oFromWB(a0),d0 * and clear it
- or.b rh_oFromWB(a5),d0
- move.b d0,rs_oFromWB(a0)
- clr.b rh_oFromWB(a5)
- CALLEXE Permit
-
- move.w #RMSG_NEWHOST,d0
- bsr _rh_WaitPutMsg
- bmi .NoGrab * RaveScope did not grab us
- beq .Fail * RaveScope wants to quit
-
- .Grabbed: DBUG "The RaveScope has grabbed us.\n" * We now have the RaveScope...
- moveq #1,d0
- .Out: POP d2-d7/a2-a4/a6
- rts
-
- .Fail: DBUG "Giving up. Returning ERROR.\n" * Ravescope not found, display
- CLEARA a0 * error message and exit.
- lea rh_RaveFailReq,a1
- CLEARA a2
- CLEARA a3
- CALLITN EasyRequestArgs
- .NoGrab: moveq #-1,d0 * Signal OK, but no grab
- bra .Out
-
- .Error: DBUG "Serious error occured!\n"
- CLEAR d0 * Signal error
- bra .Out
-
- .OpenNIL: move.l #rh_NilName,d1 * Open NIL file handle
- move.l #MODE_NEWFILE,d2
- JUMPDOS Open
-
- .CloseNILs: move.l rh_NilInput+4,d1 * Close NIL: file handles
- beq .SkipNIL1
- clr.l rh_NilInput+4
- CALLDOS Close
- .SkipNIL1: move.l rh_NilOutput+4,d1
- beq .Out
- clr.l rh_NilOutput+4
- JUMPDOS Close
-
- .FreeReq: tst.l d5 * RTFileRequest struct alloced?
- beq .NoReq
- movea.l d5,a1
- DBUG "Closing filerequester.\n"
- CALLREQ rtFreeRequest
- DBUG "Filerequester closed.\n"
- .NoReq: rts
-
- IFNE MYDEBUG
- rh_D0toASCII: PUSH d1-d2/a1 * Convert d0.l to ASCII, store
- moveq #8-1,d2 * the result in (a1)+
- .Loop: rol.l #4,d0
- move.b d0,d1
- andi.b #$F,d1
- cmpi.b #9,d1
- bgt .Letter
- add.b #'0'-('A'-$A),d1
- .Letter: add.b #'A'-$A,d1
- move.b d1,(a1)+
- dbra d2,.Loop
- POP d1-d2/a1
- rts
- ENDC
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Handle & reply to any kind of message that has arrived to the host's msgport *
- * *
- * void rh_HandleMsg(UWORD class, struct Message *msg, struct RaveHost *host) *
- * d0 a1 a5 *
- * *
- * INPUTS d0.w The recieved message's class *
- * a1.l Pointer to the message *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * FLAGS GT We have the RaveScope *
- * MI We do not have the RaveScope *
- * EQ The RaveScope is quitting (it has been released) *
- * *
- * CHANGED none *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_HandleMsg: DBUG "** Entered rh_HandleMsg.\n"
- PUSH d0-d1/a0-a1/a6
- btst #RMSGB_FROMRAVE,d0
- bne .FromRave
- DBUG "The message is from us! Returning\n"
- bra .Exit
- .FromRave: pea .Out * Return here
- cmp.w #RMSG_RAVEQUIT,d0
- beq _rh_RaveQuit
- .NoQuit: cmp.w #RMSG_LEAVERAVE,d0
- beq _rh_LostRave
- cmp.w #RMSG_GRABRAVE,d0
- beq _rh_GotRave
-
- cmp.w #RMSG_RAVEREADY,d0 * The RAVEREADY and RAVEBUSY
- beq .HReady * msgs currently don't produce
- cmp.w #RMSG_RAVEBUSY,d0 * anything more than forcing
- bne .AlienMsg * the host out from a Wait()
- DBUG "Got RMSG_RAVEBUSY.\n"
- IFNE MYDEBUG
- bra .MsgOk
- ENDC
- .HReady: DBUG "Got RMSG_RAVEREADY.\n"
- .MsgOk: move.w #RMSG_SUCCESS,rmsg_oResult(a1)
- CALLEXE ReplyMsg
- moveq #1,d0 * We have the ravescope
- rts
-
- .AlienMsg: addq.l #4,sp * This should never happen
- bsr _rh_FailMsg
- .Exit: tst.l rh_oRaveBase(a5) * Return MI if we don't have
- seq d0 * the RaveScope, GT if we do.
- addq.b #1,d0
- .Out: POP d0-d1/a0-a1/a6
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Create everything a RaveHost may need, try to load preferences, and *
- * launch/grab the RaveScope if the popup flag is set. *
- * *
- * RaveHost *h = rh_InitHost(STRPTR name, STRPTR cfg, TagItem *tags, RaveHost *h) *
- * d0 a0 a1 a2 a5 *
- * *
- * INPUTS a0.l Name of this host's player, e.g DeliTracker *
- * a1.l Complete path & name to the host's configuration file, or NULL *
- * a2.l Pointer to a list of tags or NULL (No tags defined yet!) *
- * a5.l Pointer to the hosts RaveHost structure, NULL for allocaction *
- * *
- * OUTPUTS d0.l Pointer to the RaveHost structure or NULL for failure *
- * a5.l Pointer to the RaveHost structure if successful *
- * *
- * FLAGS NE Everything went ok *
- * EQ Serious error, host must quit. *
- * *
- * CHANGED d0-d1/a0-a1(/a5) a5 only changed if originally NULL *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_InitHost: PUSH d2-d7/a2-a4/a6
- DBUG "** Entered rh_InitHost.\n"
-
- PUSH a0-a1
- move.l a5,d2
- seq d2 * Alloc mem for RaveHost struct?
- bne .StrOk * d2 = no, and don't free later
-
- DBUG "Allocating mem for Host struct.\n" * Alloc mem for the RaveHost
- move.l 4,a6 * structure if requested
- move.l #rh_SIZEOF,d0
- move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
- CALLLVO AllocVec
- move.l d0,a5
-
- .StrOk: POP a0-a1
- move.l a5,d1 * RaveHost struct exists?
- beq .Error
-
- move.b d2,rh_oFreeRHStr(a5) * Store ravehost free flag
- move.l #RAVE_ID,rh_oID(a5) * Set ID
- move.l a0,rh_oHostName(a5) * Must have a name
- beq .Error
- move.l a1,rh_oCfgName(a5) * Set configname
- clr.l rh_oCfgSize(a5) * and default size
-
- bsr _rh_OpenLibs * Open all libs
- beq .Error
- DBUG "Libraries opened OK.\n"
-
- bsr rh_Check020 * Make sure 020+ is present
- beq .Error
- DBUG "020+ found OK.\n"
-
- CLEARA a1 * Get & store a pointer to
- CALLEXE FindTask * this task
- move.l d0,rh_oThisTask(a5)
-
- bsr _rh_NukeChans * Init channel headers
-
- bsr rh_MakeMsgPort * Create the message port
- beq .Error
- DBUG "Messageport created OK.\n"
-
- move.l rh_oCfgName(a5),a0
- bsr _rh_LoadConfig * Try to load the config
- beq .Error
- DBUG "Config read/inited OK.\n"
-
- tst.b rh_oPopup(a5) * Popup?
- beq .NoPop
- bsr _rh_GrabRave
- beq .Error
- bgt .Grabbed
-
- .NoPop: DBUG "Host inited ok! Scope not grabbed.\n\n"
- move.l a5,d0
- bra .Out
- .Grabbed: DBUG "Host inited ok! Scope has been grabbed.\n\n"
- move.l a5,d0
- bra .Out
- .Error: DBUG "Host could not be inited! Returning ERROR.\n\n"
- bsr _rh_FreeHost
- CLEAR d0
- .Out: POP d2-d7/a2-a4/a6
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Load and parse the configuration file *
- * *
- * LONG success = rh_LoadConfig(UBYTE *cfgname, struct RaveHost *host) *
- * d0 a0 a5 *
- * *
- * INPUTS a0.l Full path with filename to the config to load *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.l 1, -1 or 0. Corresponds to flags below. *
- * *
- * FLAGS GT Everything went fine *
- * MI The config could not be found/loaded *
- * EQ Serious error (mem related) host must quit *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_LoadConfig: DBUG "** Entered rh_LoadConfig.\n"
- PUSH d2-d7
- CLEAR d4 * d4 = lock
- CLEAR d5 * d5 = fib
- CLEAR d6 * d6 = filehd
- moveq #-1,d7 * d7 = config not loaded yet
- move.l a0,d1 * Get config-name
- beq .NoCfg
- move.l #ACCESS_READ,d2
- DBUG "Trying to lock config.\n"
- CALLDOS Lock
- move.l d0,d4
- beq .NoCfg
-
- DBUG "Found. Allocating mem for FIB.\n" * Alloc mem for FIB
- move.l #fib_SIZEOF,d0
- move.l #MEMF_CLEAR,d1
- CALLEXE AllocVec
- move.l d0,d5
- beq .Error
-
- DBUG "Ok. Examining config.\n" * Get size of config
- move.l d4,d1
- move.l d5,d2
- CALLDOS Examine
- tst.l d0
- beq .NoCfg
- move.l d5,a0
- move.l fib_Size(a0),rh_oCfgSize(a5)
- moveq #1,d7 * Cfg will probably load
-
- .NoCfg: DBUG "Allocating mem for config.\n" * Alloc mem for config
- move.l rh_oCfgSize(a5),d0
- bne .SizeOk
- move.l #hcfg_SIZEOF,d0
- move.l d0,rh_oCfgSize(a5)
- .SizeOk: move.l #MEMF_CLEAR,d1
- CALLEXE AllocVec
- move.l d0,rh_oCfgPtr(a5)
- beq .Error
-
- tst.l d7 * Config exists?
- bmi .Reset * No, reset to default values
- moveq #-1,d7 * Assume failure
- DBUG "Trying to open config...\n"
- move.l d4,d1
- CALLDOS OpenFromLock
- move.l d0,d6
- beq .Reset
- CLEAR d4 * Can't use lock anymore now!
-
- DBUG "Ok. Reading it.\n"
- move.l d0,d1 * Read the config
- move.l rh_oCfgPtr(a5),d2
- move.l rh_oCfgSize(a5),d3
- CALLLVO Read
- not.l d0
- beq .Reset
-
- move.l ([rh_oCfgPtr,a5],hcfg_oID),d0 * Config-ID correct?
- cmp.l rh_oID(a5),d0
- bne .WrongID
- moveq #1,d7 * Set definite success
- bra .Parse
-
- .WrongID: DBUG "OBSOLETE CONFIG FILE!\n"
- .Reset: bsr _rh_ResetCfg
-
- .Parse: bsr _rh_ParseCfg
- bsr .Close * Close fib/lock/hd & ret OK
- move.l d7,d0
- .Out: POP d2-d7
- rts
-
- .Error: bsr .Close * Close fib/lock/hd & ret ERR
- CLEAR d0
- bra .Out
-
- .Close: move.l d6,d1 * Close config-file?
- beq .NoCl
- DBUG "Closing config-file.\n"
- CALLDOS Close
-
- .NoCl: tst.l d5 * Free FIB?
- beq .NoFr
- DBUG "Freeing FIB.\n"
- move.l d5,a1
- CALLEXE FreeVec
-
- .NoFr: move.l d4,d1 * Unlock config?
- beq .NoUl
- DBUG "Unlocking config.\n"
- JUMPDOS UnLock
- .NoUl: rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Handle the RMSG_LEAVERAVE message and reply it with the success code set. *
- * *
- * void rh_LostRave(struct Message *msg, struct RaveHost *host) *
- * a1 a5 *
- * *
- * INPUTS a1.l Pointer to the message *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * FLAGS MI Always set *
- * *
- * CHANGED d0-d1/a0-a1/a6 (a6 = SysBase) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_LostRave: DBUG "Releasing the RaveScope.\n"
- DBUG "Replying to RMSG_LEAVERAVE message.\n"
- clr.l rh_oRaveBase(a5) * Release it
- move.w #RMSG_SUCCESS,rmsg_oResult(a1) * And return success
- CALLEXE ReplyMsg
- moveq #-1,d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Clear all the host's channel structures, and mark them as containing invalid *
- * data. The RaveScope will not even attempt to display them until you have *
- * updated them. *
- * *
- * void rh_NukeChans(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED none *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_NukeChans: PUSH d7/a4
- lea rh_oChanHdrs(a5),a4 * a4 = ptr to chan headers
- moveq #3-1,d7 * Reset all 3 of them
-
- .Reset: bset.b #SCPHB_INVALID,scph_oFlags(a4) * Not yet valid for display
- clr.l scph_oFreshness(a4) * Reset freshness
- clr.w scph_oNumChans(a4) * No channels to display
- bsr _rh_ClrChans
- adda.w #scph_SIZEOF,a4 * Go to next ScopeHeader
- dbra d7,.Reset
- POP d7/a4
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Open dos.library, intuition.library and reqtools.library and set SysBase. *
- * Done automatically in rh_InitHost. *
- * *
- * BOOL success = rh_OpenLibs(struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.l 0 for failure *
- * *
- * FLAGS EQ All libraries could not be opened *
- * NE All libraries was opened ok *
- * *
- * CHANGED d0 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_OpenLibs: PUSH d1/d7/a0-a4
- DBUG "Opening libraries...\n"
- move.l 4.w,rh_oSysBase(a5) * Execbase to fastmem
- lea .LP,a3
- lea rh_oDOSBase(a5),a4
- moveq #3-1,d7 * Open dos,int,reqt
-
- .OpenLib: movem.w (a3)+,d0/d1 * d0=version#,d1=nameofs
- lea .LP(pc,d1),a2 * a2=library name
- move.l a2,a1
- tst.l (a4)+ * Library not already open?
- bne .SkipLib
-
- CALLEXE OpenLibrary * Open it
- move.l d0,-4(a4) * Store
- .SkipLib: dbeq d7,.OpenLib
- bne .Done
- bsr _rh_CloseLibs * Close any opened lib
- bsr rh_ErrOpenA2 * Display error message
- .Done: POP d1/d7/a0-a4
- rts
-
- .LP: dc.w 39,.DN-.LP,39,.IN-.LP * Library name pointers and
- dc.w REQTOOLSVERSION,.RN-.LP * required version numbers
- .DN: dc.b "dos.library",0
- .IN: dc.b "intuition.library",0
- .RN: dc.b "reqtools.library",0
- EVEN
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Parse the config, so the variables in the RaveHost structure reflects it *
- * *
- * void rh_ParseConfig(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * CHANGED d0-d1/a0-a1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_ParseCfg: DBUG "Parsing config.\n"
- move.l rh_oCfgPtr(a5),a0
- move.l hcfg_oPopup(a0),rh_oPopup(a5) * Set popup flags from config
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Call this when the host starts playing. It will set the host's play-flag and *
- * notify the RaveScope of this. If the host does not have the RaveScope, it will *
- * try to grab it. *
- * *
- * void rh_PlyActive(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_PlyActive: DBUG "** Entered rh_PlyActive\n"
- move.w #RMSG_PLYACTIVE,d0
- st rh_oPlaying(a5) * We're playing now
- tst.l rh_oRaveBase(a5) * Do we have the RaveScope?
- bne _rh_WaitPutMsg * Yes, send message
-
- DBUG "Trying to grab RaveScope by force\n" * No, try to grab it
- move.w #RMSG_NEWHOST,d0
- jsr _rh_WaitPutMsg
- ble .Out * Could not be grabbed
-
- move.w #RMSG_PLYACTIVE,d0 * Tell the RaveScope (if we
- jmp _rh_SignalRave * still have it) we're playing
- .Out: rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Handle & reply to all messages that has arrived to the host's msgport. *
- * *
- * LONG result = rh_ProcMsgs(struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.l 1, -1 or 0. Corresponds to flags below. *
- * *
- * FLAGS GT We have the RaveScope *
- * MI We do not have the RaveScope *
- * EQ The RaveScope is quitting (it has been released) *
- * *
- * CHANGED d0 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_ProcMsgs: DBUG "** Entered rh_ProcMsgs.\n"
- PUSH d1/a0-a1/a6
- .GetMsg: bsr _rh_GetMsg * Get a message
- beq .Exit * No more!
- move.l d0,a1
- move.w d1,d0
- bsr _rh_HandleMsg * Handle the message
- bne .GetMsg * No quit-message => check next
- CLEAR d0
- .Out:
- IFNE MYDEBUG
- DBUG "-> Leaving rh_ProcMsgs.\n"
- tst.l d0
- ENDC
- POP d1/a0-a1/a6 * Got quit-message, exit EQ
- rts
- .Exit: tst.l rh_oRaveBase(a5) * Return MI if we don't have
- seq d0 * the RaveScope, GT if we do.
- extb.l d0
- bmi .Out
- moveq #1,d0
- bra .Out
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK PutMsg() a RaveMsg to the RaveScope. *
- * *
- * BOOL success = rh_PutMsg(UWORD msgclass, struct RaveHost *host) *
- * d0 d0 a5 *
- * *
- * INPUTS d0.w The message class, for example RMSG_HOSTQUIT *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.w TRUE or FALSE, corresponds to flags below. *
- * *
- * FLAGS EQ The message could not be sent *
- * NE The message was sent *
- * *
- * CHANGED d0/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_PutMsg: PUSH d0-d3/a0-a1
- move.w d0,d2 * Remember the message class
- CLEAR d3 * d3 = we have not called Forbid()
- move.l rh_oRaveBase(a5),d0 * Do we have the RaveScope?
- bne .RaveOk * Yes
- CLEAR d0 * No, try to find it
- bsr _rh_FindRave * (wait 0 secs)
- beq .Out * Could not be found.
- moveq #1,d3 * Found, remember to Permit()
-
- .RaveOk: cmp.w #RMSG_HOSTQUIT,d2 * Send RMSG_HOSTQUIT?
- bne .NoQuit
- st rh_oHostQuit(a5) * Mark this host as quitting
-
- .NoQuit: move.l d0,a0 * Send the message
- bsr _rh_AllocMsg
- beq .Out
- move.l d0,a1
- move.w d2,rmsg_oType(a1)
-
- IFNE MYDEBUG
- SFORBID
- DBUG "Sending "
- PUSH a0
- move.w d2,d0
- bsr _rh_IdentMsg
- DBUGIT (a0)
- LEASTR " to ",a0
- DBUGIT (a0)
- POP a0
- move.l LN_NAME(a0),a2
- tst.l a2
- bne .NameOk
- LEASTR "UNKNOWN PORT!",a2
- .NameOk: DBUGIT (a2)
- LEASTR "\n",a2
- DBUGIT (a2)
- ENDC
-
- CALLEXE PutMsg
- IFNE MYDEBUG
- SPERMIT
- ENDC
- tst.w d3 * Do we need to Permit() ?
- beq .Exit * No
- CALLLVO Permit
- .Exit: moveq #1,d0 * Set success
- .Out: POP d0-d3/a0-a1
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Handle the RMSG_RAVEQUIT message and reply it with the success code set. *
- * *
- * void rh_RaveQuit(struct Message *msg, struct RaveHost *host) *
- * a1 a5 *
- * *
- * INPUTS a1.l Pointer to the message *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * FLAGS EQ Always set *
- * *
- * CHANGED d0-d1/a0-a1/a6 (a6 = SysBase) *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_RaveQuit: DBUG "Releasing the RaveScope.\n"
- DBUG "Replying to RMSG_RAVEQUIT message.\n"
- clr.l rh_oRaveBase(a5) * Release it
- move.w #RMSG_SUCCESS,rmsg_oResult(a1) * And return success
- CALLEXE ReplyMsg
- moveq #0,d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Remove given signal (d0) from the signal mask *
- * *
- * void rh_RemSig(BYTE signal, struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS d0.b Signal number *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * CHANGED d1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_RemSig: move.l rh_oSigMask(a5),d1
- bclr.l d0,d1
- move.l d1,rh_oSigMask(a5)
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Reset the configuration file to default values (but don't clear it) *
- * *
- * void rh_ResetConfig(struct RaveHost *host) *
- * a5 *
- * *
- * INPUTS a5.l Pointer to the host's RaveHost structure *
- * *
- * CHANGED d0-d1/a0-a1 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_ResetCfg: DBUG "Resetting config to default.\n"
- move.l rh_oCfgPtr(a5),a1
- move.l #RAVE_ID,hcfg_oID(a1) * Reset ID
- move.l #$FF0000FF,hcfg_oPopup(a1) * Set popup related flags
- clr.b hcfg_oRaveName(a1) * Reset ravename
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Send a message to the RaveScope (and wait for reply) IF WE HAVE IT. *
- * Just exit Z set if we don't. *
- * *
- * void rh_SignalRave(UWORD msgclass, struct RaveHost *host) *
- * d0 a5 *
- * *
- * INPUTS d0.w The message class, for example RMSG_PLYHALTED *
- * a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS none *
- * *
- * FLAGS GT Message was sent and handled successfully. *
- * MI The message was sent, but was not successful. *
- * EQ The RaveScope is not present/wants to quit. *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_SignalRave: DBUG "** Entered rh_SignalRave.\n"
- tst.l rh_oRaveBase(a5) * Do we have the RaveScope?
- bne _rh_WaitPutMsg * Yes, send message
- rts * No, so don't try to msg it
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * Send a message to the RaveScope IF WE HAVE IT. Just exit Z set if we don't. *
- * *
- * BOOL success = rh_TellRave(UWORD msgclass, struct RaveHost *host) *
- * d0 d0 a5 *
- * *
- * INPUTS d0.w The message class, for example RMSG_PLYHALTED *
- * a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.w TRUE or FALSE, corresponds to flags below. *
- * *
- * FLAGS EQ The message could not be sent *
- * NE The message was sent *
- * *
- * CHANGED d0/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_TellRave: DBUG "** Entered rh_TellRave.\n"
- tst.l rh_oRaveBase(a5) * Do we have the RaveScope?
- bne _rh_PutMsg * Yes, send message
- CLEAR d0 * No, so don't try to msg it
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * If the host has the RaveScope, find a channel header that can be updated and *
- * check that it has enough channel-structures attached to it (allocate mem for *
- * them if not) then call the supplied routine in a0, that must update the *
- * channel structures. This routine will be called with a4=ptr to the channel *
- * header and a5=the ravehost structure. It must return d0=1 if the channels *
- * were updated, d0=0 if they were not and d0=-1 for serious error. It may not *
- * change a4 or a5. *
- * *
- * LONG result=rh_UpdateChans(UWORD maxchans, LONG (*update_func), RaveHost *host) *
- * d0 d1 a2 a5 *
- * *
- * INPUTS d1.w Make sure there's room for d1 channels, or if d1=0: don't care *
- * a2.l Pointer to the routine that updates the structure *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.l 1, 0 or -1, corresponds to flags below *
- * *
- * FLAGS GT The channels were updated *
- * EQ The channels were not updated *
- * MI Serious error (out of mem etc), host should quit *
- * *
- * CHANGED d0-d7/a0-a4/a6 *
- * *
- * *
- * Here's the specifications that your routine to update the channel *
- * structures must conform to... *
- * *
- * LONG result = update_func(struct ScopeHeader *head, struct RaveHost *host) *
- * d0 a4 a5 *
- * *
- * INPUTS a4.l Pointer to the scopeheader structure to update (always valid) *
- * a5.l Pointer to the host's RaveHost structure *
- * *
- * OUTPUTS d0.l 1 if you could update the channel structures, *
- * 0 if you could not, *
- * -1 if a serious error occured. *
- * *
- * CHANGED d0-d7/a0-a3/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_UpdateChans tst.l rh_oRaveBase(a5) * Are we used by the RaveScope?
- beq .Exit * No, exit.
- lea rh_oChanHdrs(a5),a0 * Find a header to update
- moveq #3-1,d0
- jsr ([rh_oGet4Upd_f,a5]) * Get d0=header struct to update
- beq .Exit * None available => exit
- move.l d0,a4 * a4=header to update
-
- tst.w d1 * Check if there's enough room?
- beq .NoCheck * No, always enough
- cmp.w scph_oMaxChans(a4),d1 * Enough room?
- ble .NoCheck * Yes
- move.w d1,d0 * New #of channels
- moveq #3-1,d1 * Three sets of chanstructs
- lea rh_oChanHdrs(a5),a0 * Pointer to channel headers
- jsr ([rh_oMakeRoom_f,a5]) * Ensure there's room for all chans
- beq .Error * It isn't, error!
-
- .NoCheck: jsr (a2) * Update them!
- tst.l d0 * Succesful?
- beq .Fail * No, just exit
- and.b #~(SCPHF_INVALID!SCPHF_UPDATED),scph_oFlags(a4) * Not invalid/being upd
- tst.l d0
- rts
- .Exit: CLEAR d0
- rts
- .Error: moveq #-1,d0
- rts
- .Fail: DBUG "rh_UpateChans failed!\n"
- and.b #~SCPHF_UPDATED,scph_oFlags(a4) * Struct is no longer being updated
- tst.l d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK Wait for the specified message to return. Unrelated messages will be *
- * replied to with the failurecode set, unless it is RMSG_RAVEQUIT, in *
- * which case this routine will exit EQ. The message we're waiting on will *
- * be replied to with the successcode set. *
- * *
- * LONG result = rh_WaitMsg(UWORD msgclass, struct RaveHost *host) *
- * d0 d0 a5 *
- * *
- * INPUTS d0.w The message class, for example RMSG_HOSTQUIT *
- * a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.l 1, -1 or 0, corresponds to flags below *
- * *
- * FLAGS GT Message returned with its success code set *
- * MI Message returned with its failure code set *
- * EQ The RaveScope wants to quit. *
- * *
- * CHANGED d0 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_WaitMsg: PUSH d1-d3/a0-a1/a6
- IFNE MYDEBUG
- SFORBID
- DBUG "** Entered rh_WaitMsg, want " * Wait for reply to arrive
- bsr _rh_IdentMsg
- DBUGIT (a0)
- LEASTR "\n",a0
- DBUGIT (a0)
- SPERMIT
- ENDC
-
- move.w d0,d2 * d2 = message class to wait for
- .W8Reply: move.l a5,a0 * Wait until we get a message
- DBUG "Going to sleep...\n"
- CALLEXE WaitPort
- bsr _rh_GetMsg
- beq .W8Reply
- move.l d0,a1
-
- cmp.w d1,d2 * Is it the one we're waiting on?
- beq .GotReply
-
- btst #RMSGB_FROMHOST,d1 * No. Is it from us?
- beq .FromRave * No, from the RaveScope
- bsr _rh_FreeMsg * Yes, free this message and
- bra .W8Reply * keep waiting
- .FromRave: cmp.w #RMSG_RAVEQUIT,d1 * Is it a quit-message?
- bne .NoQuit * No
- bsr _rh_RaveQuit * Yes, handle it
- bra .Quit
- .NoQuit: bsr _rh_FailMsg * Fail all other messages
- bra .W8Reply
-
- .GotReply: DBUG "Got the msg we were waiting on.\n"
- move.w rmsg_oResult(a1),d3 * Remember result
- btst #RMSGB_FROMHOST,d1 * Was it from us?
- bne .NoReply * Yes, so don't reply to it
- moveq #1,d3 * No, from the RaveScope, set
- move.w d1,d0 * success and reply to it
- bsr _rh_HandleMsg
- bra .Exit
-
- .NoReply: bsr _rh_FreeMsg * Free our message.
- cmp.w #RMSG_NEWHOST,d2 * Did we wait on the NEWHOST msg?
- bne .Exit * No, exit
- tst.w d3 * Yes, did it succeed?
- bne .NHostOk
- DBUG "The RMSG_NEWHOST msg failed!\n"
- bra .Fail
-
- .NHostOk: DBUG "We got the RMSG_NEWHOST msg back OK. Now we must wait for RMSG_GRABRAVE!\n"
- move.w #RMSG_GRABRAVE,d0 * Yes, so we must wait on the
- bsr _rh_WaitMsg * RMSG_GRABRAVE as well. Call it...
- beq .Quit * Rave is quitting
-
- .Exit: tst.w d3 * Message successful?
- beq .Fail * No
- DBUG "Exiting rh_WaitMsg : SUCCESS\n"
- moveq #1,d0 * Yes
- .Out: POP d1-d3/a0-a1/a6 * Report SUCCESS
- rts
- .Fail: DBUG "Exiting rh_WaitMsg : FAILURE\n"
- moveq #-1,d0 * Report FAILURE
- bra .Out
- .Quit: DBUG "Exiting rh_WaitMsg : RAVEQUIT\n"
- CLEAR d0 * Report RAVE QUIT
- bra .Out
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- * *
- * TASK PutMsg() a RaveMsg to the RaveScope and wait for reply. Unrelated *
- * messages will be replied to with the failurecode set, unless it *
- * is RMSG_RAVEQUIT, in which case this routine will exit EQ. *
- * *
- * LONG result = rh_WaitPutMsg(UWORD msgclass, struct RaveHost *host) *
- * d0 d0 a5 *
- * *
- * INPUTS d0.w The message class, for example RMSG_HOSTQUIT *
- * a5.l Pointer to the hosts RaveHost structure *
- * *
- * OUTPUTS d0.l 1, -1 or 0, corresponds to flags below *
- * *
- * FLAGS GT Message was sent and handled successfully. *
- * MI The message was sent, but was not successful. *
- * EQ The RaveScope is not present/wants to quit. *
- * *
- * CHANGED d0-d1/a0-a1/a6 *
- * *
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
- _rh_WaitPutMsg: PUSH d0-d2/a0-a1
- move.w d0,d2 * d2 = message class
- bsr _rh_PutMsg
- bne .MsgOk
- DBUG "Could not send the message!\n"
- CLEAR d0
- bra .Out
- .MsgOk: move.w d2,d0
- bsr _rh_WaitMsg
- IFNE MYDEBUG
- beq .RaveQuit
- bmi .Failure
- DBUG "Msg returned successfully!\n"
- moveq #1,d0
- bra .Out
- .RaveQuit: DBUG "The RaveScope wants to quit!\n"
- CLEAR d0
- bra .Out
- .Failure: DBUG "The msg was not successful!\n"
- moveq #-1,d0
- ENDC
- .Out: POP d0-d2/a0-a1
- rts
-
-
-
-
-
-
-
- * Private functions and data now follow *
-
-
-
-
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Check for 020+
-
- rh_Check020: move.l rh_oSysBase(a5),a0
- move.w AttnFlags(a0),d0
- and.w #AFF_68020,d0 * 020 or above present?
- bne .Exit * Yes
- DBUG "No 020 found!\n"
- CLEARA a0 * error message and exit.
- lea rh_No020Req,a1
- CLEARA a2
- CLEARA a3
- CALLITN EasyRequestArgs
- CLEAR d0
- .Exit: rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Create a message port
-
- rh_MakeMsgPort: DBUG "** Entered rh_MakeMsgPort.\n"
- CALLEXE Forbid
- DBUG "Trying to find a portname that is not in use...\n"
-
- move.b #'0'-1,rh_RHPortNmID * Reset portname's ID
- .FindName: addq.b #1,rh_RHPortNmID * Increase ID
- lea rh_RHPortName,a1 * Find a portname that is not
- CALLLVO FindPort * in use
- tst.l d0 * This one in use?
- bne .FindName * Yes, try next
-
- DBUG "Creating message port...\n" * Alloc signal
- bsr _rh_AllocSig
- move.b d0,rh_oSignal(a5)
- bmi .Error
-
- move.b d0,MP_SIGBIT(a5)
- move.l #rh_RHPortName,LN_NAME(a5) * Init the messageport
- move.b #1,LN_PRI(a5)
- move.b #NT_MSGPORT,LN_TYPE(a5)
- move.b #PA_SIGNAL,MP_FLAGS(a5)
- move.l rh_oThisTask(a5),MP_SIGTASK(a5)
- lea rh_oMsgPort(a5),a1
- CALLLVO AddPort
- CALLLVO Permit
- st rh_oMsgPortOk(a5)
- moveq #1,d0
- rts
-
- .Error: CALLLVO Permit
- ERRMSG "Couldn't create messageport!"
- moveq #0,d0
- rts
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Free the message port
-
- rh_FreeMsgPort: DBUG "** Entered rh_FreeMsgPort.\n"
- tst.b rh_oMsgPortOk(a5) * Message port created?
- beq .Exit
- clr.b rh_oMsgPortOk(a5)
-
- DBUG "RemPort()ing...\n" * Remove the port so that the
- lea rh_oMsgPort(a5),a1 * RaveScope cannot find it again
- CALLEXE RemPort
-
- tst.l rh_oRaveBase(a5) * Do we have the ravescope?
- beq .NoQuitMsg * No, don't send it quitmessage
- move.w #RMSG_HOSTQUIT,d0 * Yes, tell it we're quitting
- bsr _rh_WaitPutMsg
-
- .NoQuitMsg: DBUG "Emptying our port from messages.\n"
- CALLEXE Forbid * No more messages wanted
- .EmptyPort: bsr _rh_GetMsg * Try to get a message
- beq .PortEmpty * No more remains!
- move.l d0,a1
- cmp.w #RMSG_RAVEQUIT,d1 * RAVEQUIT message?
- bne .FailMsg * No, just return it
- bsr _rh_RaveQuit * Yes, handle it
- bra .EmptyPort
- .FailMsg: btst #RMSGB_FROMHOST,d1 * Not one of our messages?
- bne .EmptyPort * Yes, just ignore it
- bsr _rh_FailMsg * No, return it with FAILURE
- bra .EmptyPort
-
- .PortEmpty: DBUG "Port empty, freeing signal bit.\n"
- lea rh_oSignal(a5),a0
- bra _rh_FreeSig * Free the related signal
- .Exit: rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Free any allocated channel structures from the channel headers
-
- rh_FreeChHds: DBUG "Freeing channel structures.\n"
- moveq #3-1,d2
- lea rh_oChanHdrs(a5),a2
- .Free: move.l scph_oChannels(a2),d1
- beq .Skip
- clr.l scph_oChannels(a2)
- move.l d1,a1
- CALLEXE FreeVec
- .Skip: add.w #scph_SIZEOF,a2
- dbra d2,.Free
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Free the RaveHost structure if this was allocated in rh_InitHost.
-
- rh_FreeRHStr: tst.b rh_oFreeRHStr(a5) * Must free it?
- beq .Exit * No
- DBUG "Freeing the RaveHost structure.\n"
- clr.b rh_oFreeRHStr(a5)
- move.l a5,a1
- CLEARA a5
- JUMPEXE FreeVec
- .Exit: rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Free the memory allocated for the config (if any)
-
- rh_FreeCfg: move.l rh_oCfgPtr(a5),d0
- beq .Exit
- DBUG "Freeing config memory.\n"
- clr.l rh_oCfgPtr(a5)
- move.l d0,a1
- JUMPEXE FreeVec
- .Exit: rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Error routines
-
- rh_ErrOpenA2: lea rh_ErrSpace,a3 * Unable to open <name of object
- .CopyErr: move.b (a2)+,(a3)+ * that failed supplied in a2>
- bne .CopyErr
- SETERR #rh_ErrOpenTxt
- CLEAR d0
- rts
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Debug routine that returns a pointer to the name of a message
- * INPUTS d0 Type of the message
- * OUTPUTS a0 Name of the message
- * CHANGED a0
-
- IFNE MYDEBUG
- XDEF _rh_IdentMsg
- _rh_IdentMsg: PUSH d0
- lea .TypePtrs-2,a0
- .FindIt: add.w #2,a0
- tst.w (a0)
- beq .Alien
- cmp.w (a0)+,d0
- bne .FindIt
- move.w (a0),d0
- lea .TypePtrs(pc,d0.w),a0
- POP d0
- rts
- .Alien: LEASTR "!!ALIEN MSG!!",a0
- POP d0
- rts
-
- .TypePtrs: dc.w RMSG_RAVEQUIT,.RAVEQUIT-.TypePtrs
- dc.w RMSG_RAVEBUSY,.RAVEBUSY-.TypePtrs
- dc.w RMSG_RAVEREADY,.RAVEREADY-.TypePtrs
- dc.w RMSG_LEAVERAVE,.LEAVERAVE-.TypePtrs
- dc.w RMSG_GRABRAVE,.GRABRAVE-.TypePtrs
- dc.w RMSG_ADDPORTS,.ADDPORTS-.TypePtrs
- dc.w RMSG_DELPORTS,.DELPORTS-.TypePtrs
- dc.w RMSG_POKESTICK,.POKESTICK-.TypePtrs
- dc.w RMSG_NEWHOST,.NEWHOST-.TypePtrs
- dc.w RMSG_PLYHALTED,.PLYHALTED-.TypePtrs
- dc.w RMSG_PLYACTIVE,.PLYACTIVE-.TypePtrs
- dc.w RMSG_HOSTBUSY,.HOSTBUSY-.TypePtrs
- dc.w RMSG_HOSTREADY,.HOSTREADY-.TypePtrs
- dc.w RMSG_HOSTQUIT,.HOSTQUIT-.TypePtrs
- dc.w RMSG_CLOSESCOPE,.CLOSESCOPE-.TypePtrs
- dc.w RMSG_OPENSCOPE,.OPENSCOPE-.TypePtrs
- dc.w RMSG_KILLRAVE,.KILLRAVE-.TypePtrs
- dc.w RMSG_HIPHALTED,.HIPHALTED-.TypePtrs
- dc.w RMSG_HIPACTIVE,.HIPACTIVE-.TypePtrs
- dc.w RMSG_LOSTHIP,.LOSTHIP-.TypePtrs
- dc.w RMSG_DOICONIFY,.DOICONIFY-.TypePtrs
- dc.w RMSG_DEICONIFY,.DEICONIFY-.TypePtrs
- dc.w RMSG_SAVECONFIG,.SAVECONFIG-.TypePtrs
- dc.w 0,0
-
- .RAVEQUIT dc.b "RMSG_RAVEQUIT",0
- .RAVEBUSY dc.b "RMSG_RAVEBUSY",0
- .RAVEREADY dc.b "RMSG_RAVEREADY",0
- .LEAVERAVE dc.b "RMSG_LEAVERAVE",0
- .GRABRAVE dc.b "RMSG_GRABRAVE",0
- .ADDPORTS dc.b "RMSG_ADDPORTS",0
- .DELPORTS dc.b "RMSG_DELPORTS",0
- .POKESTICK dc.b "RMSG_POKESTICK",0
- .NEWHOST dc.b "RMSG_NEWHOST",0
- .PLYHALTED dc.b "RMSG_PLYHALTED",0
- .PLYACTIVE dc.b "RMSG_PLYACTIVE",0
- .HOSTBUSY dc.b "RMSG_HOSTBUSY",0
- .HOSTREADY dc.b "RMSG_HOSTREADY",0
- .HOSTQUIT dc.b "RMSG_HOSTQUIT",0
- .CLOSESCOPE dc.b "RMSG_CLOSESCOPE",0
- .OPENSCOPE dc.b "RMSG_OPENSCOPE",0
- .KILLRAVE dc.b "RMSG_KILLRAVE",0
- .HIPHALTED dc.b "RMSG_HIPHALTED",0
- .HIPACTIVE dc.b "RMSG_HIPACTIVE",0
- .LOSTHIP dc.b "RMSG_LOSTHIP",0
- .DOICONIFY: dc.b "RMSG_DOICONIFY",0
- .DEICONIFY: dc.b "RMSG_DEICONIFY",0
- .SAVECONFIG: dc.b "RMSG_SAVECONFIG",0
- ENDC
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Window texts
-
- rh_Version: dc.b "RaveScope 1.2 by Parsec 1998",0
- rh_No020Txt: dc.b "Sorry, cannot start the RaveScope.",10,10
- dc.b "This program requires a 68020 or better.",0
-
- rh_RaveFailTxt: dc.b "The RaveScope could not be started.",10
- dc.b "Maybe you have specified its path",10
- dc.b "incorrectly.",0
-
- rh_OkText: dc.b " Ok ",0
- rh_OhText: dc.b " Oh ",0
-
- EVEN
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * TextRequesters
-
- rh_No020Req: dc.l EasyStruct_SIZEOF * size
- dc.l 0 * Flags
- dc.l rh_Version * Title
- dc.l rh_No020Txt * TextFormat
- dc.l rh_OhText * GadgetFormat
-
- rh_RaveFailReq: dc.l EasyStruct_SIZEOF * size
- dc.l 0 * Flags
- dc.l rh_Version * Title
- dc.l rh_RaveFailTxt * TextFormat
- dc.l rh_OkText * GadgetFormat
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- * Tag lists
-
- rh_ReqTags: dc.l RT_ReqPos,REQPOS_CENTERWIN,TAG_END * Ravescope file request tags
-
- rh_ExeTags: dc.l SYS_Asynch,-1 * Run asynchronos
- rh_NilOutput: dc.l SYS_Output,0 * NIL: output file hd
- rh_NilInput: dc.l SYS_Input,0 * NIL: input file hd
- dc.l TAG_DONE
-
- rh_ErrOpenTxt: dc.b "Unable to open "
- rh_ErrSpace: ds.b 20
-
- rh_RHPortName: dc.b 'RaveScope-Host.' * The hosts msgports are named
- rh_RHPortNmID: dc.b '0',0 * RaveScope-Host.x (x=ID, 0 & up)
- rh_RSPortName: dc.b 'RaveScope',0
- rh_NilName: dc.b 'NIL:',0
- rh_AskFileTxt: dc.b "Select the RaveScope executable...",0 * Ravescope exe file select text
- rh_DRCfgKey: dc.b " ",0
-
-
- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
- *
- *
- SECTION RaveHostBSS,BSS
- *
- *
-
- rh_FileName: ds.b 108 * RaveScope's filename, 4 reqtools
-
-
-
-